package javapoker.view;

import java.awt.Color;
import java.awt.Font;

import javapoker.Card;
import javapoker.Card.CRank;
import javapoker.Card.CSuit;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JToggleButton;

import net.miginfocom.swing.MigLayout;
import javax.swing.border.BevelBorder;
import javax.swing.BoxLayout;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.SpringLayout;
import java.awt.GridLayout;

public class CardView extends JPanel {

	
	private JLabel lblCardText;
	private JLabel lblPicture;
	private JToggleButton tglbtnKeep;
	/**
	 * Create the panel.
	 */
	public CardView() 
	{
		this(new Card(CRank.UNKNOWN, CSuit.UNKNOWN));
	}
	public CardView(Card view)
	{
		init();
		setCard(view);
	}
	
	
	private void init()
	{
		
		setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));
		setLayout(new GridLayout(0, 1, 0, 0));
		
		lblCardText = new JLabel("Card Text");
		lblCardText.setForeground(Color.BLUE);
		lblCardText.setToolTipText("Card Text");
		lblCardText.setFont(new Font("DejaVu Sans", Font.BOLD, 12));
		
		tglbtnKeep = new JToggleButton("Keep");
		
		
		lblPicture = new JLabel("Picture");
		lblPicture.setBackground(Color.PINK);
		lblPicture.setFont(new Font("Dialog", Font.BOLD, 12));
		
		attachElements();
	}
	
	/**
	 * Seperate method because some elements may not be added, effort to keep modularized
	 */
	private void attachElements()
	{
		//add(lblCardText);
		//add(tglbtnKeep);
		add(lblPicture);
	}
	

	public void setCard(Card view)
	{
		Color color = null;
		switch (view.getSuit()) {
		
		case DIAMONDS:
		case HEARTS:
			color = Color.RED;
			break;
		case CLUBS:
		case SPADES:
			color = Color.BLACK;
			break;
		default:
			color = Color.GREEN;
			break;
		}
		
		lblCardText.setForeground(color);
		lblCardText.setText(view.toString());

		lblPicture.setForeground(color);
		lblPicture.setText(view.toShortString());
		lblPicture.setToolTipText(view.toShortString());
	}

}
